package easycloud.ecs.web.service;

import java.util.List;

import javax.inject.Inject;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import easycloud.ecs.common.domain.Sync;
import easycloud.ecs.common.domain.User;
import easycloud.ecs.common.repository.SyncRepository;

@Service
@Transactional(readOnly = true)
public class SyncService {

	private static final Log logger = LogFactory.getLog(SyncService.class);
	
	@Inject
	private SyncRepository syncRepository;

	@Transactional(readOnly = false)
	public void save(Sync sync) {
		syncRepository.save(sync);
	}

	public Sync getSync(Integer syncId) {
		return syncRepository.findOne(syncId);
	}

	@Transactional(readOnly = false)
	public void delete(Sync sync) {
		syncRepository.delete(sync);
	}

	public List<Sync> findSync(User user) {
		return syncRepository.findByUser(user);
	}

}
